Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add api key and admin API #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

shrimalmadhur
Copy link
Collaborator

@shrimalmadhur shrimalmadhur commented Dec 10, 2024

  • Add API key to generate and import response
  • Add Admin APIs

Why this API change

Problem

Multiple AVS can use single Cerberus instance to sign with their key by sending the public key in the request. This creates a problem with a malicious AVS can ask keys from other AVS to sign. We need a way to make sure AVS1 can only sign with keys registered from them. Following are some potential ways we can solve this problem

Solution

Every new BLS key pair which is either created or imported will return a new API Key. This will be a unique identifier (uuid) for authorizing the key to sign. In Cerberus we will persist the mapping of hash of API Key and public key (with some other metadata). All the signing requests should come with API Key and if that API key doesn’t match with the public key it is mapped with, Cerberus will reject the request.

Sample Go Client code

import "google.golang.org/grpc/metadata"

ctx = metadata.AppendToOutgoingContext(ctx, "authorization", api_key)

Sample cerberus validation code

md, ok := metadata.FromIncomingContext(ctx)
if !ok {
	return nil, status.Errorf(codes.Unauthenticated, "metadata is not provided")
}

values := md["authorization"]
if len(values) == 0 {
	return nil, status.Errorf(codes.Unauthenticated, "authorization token is not provided")
}
	
	
// Check if this value matches the pub key in the request
  • Cerberus will implement a persistant storage to store these mappings
  • Admin API will be exposed on separate port so a super admin can expose them to a bastion server for any API Key rotation or locking/unlocking keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant